package com.briup.cms.service.impl;

import com.briup.cms.bean.Article;
import com.briup.cms.dao.ArticleMapper;
import com.briup.cms.service.IArticleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleServiceImpl implements IArticleService {
    @Resource
    private ArticleMapper articleMapper;

    @Override
    public List<Article> findAll() {
        List<Article> list=articleMapper.selectAll();
        return list;
    }

    @Override
    public void saveOrUpdate(Article article) {
        if(article.getId()!=null){
            articleMapper.update(article);
        } else {
            articleMapper.insert(article);
        }
    }

    @Override
    public void deleteById(long id) {
        articleMapper.deleteById(id);
    }

}
